/*!
    \file    change log.txt
    \brief   change log for GD32F20x demo

    \version 2025-08-11, V2.9.0, demo for GD32F20x
*/

/*
    Copyright (c) 2025, GigaDevice Semiconductor Inc.

    Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this 
       list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice, 
       this list of conditions and the following disclaimer in the documentation 
       and/or other materials provided with the distribution.
    3. Neither the name of the copyright holder nor the names of its contributors 
       may be used to endorse or promote products derived from this software without 
       specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
*/

******************* V2.9.0 2025-08-11 ******************************************************************************************
______________________Common______________________________________________________________________________________________

__________________________________________________________________________________________________________________________

_____________________ ADC ________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________BKP_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________CAN_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________CAU_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________CRC_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________DAC_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________DBG_________________________________________________________________________________________________

________________________________________________________________________________________________________________________

______________________DCI_________________________________________________________________________________________________

____________________________________________________________________________________________________________________

______________________DMA_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________ENET________________________________________________________________________________________________

________________________________________________________________________________________________________________

______________________EXMC________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________EXTI________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________FMC_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________FWDGT_______________________________________________________________________________________________

___________________________________________________________________________________________________________________________

______________________GPIO________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________HAU_________________________________________________________________________________________________
Fix file:
/GD32F20x_Demo_Suites/GD32F207C_EVAL_Demo_Suites/Projects/16_HAU/main.c
fix reason:
Modify demo
V2.8.0:
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    gd_eval_com_init(EVAL_COM0);
    /* enable HAU clock */
    rcu_periph_clock_enable(RCU_HAU);

    len = sizeof(message_input) - 1;
    key_len = sizeof(key) - 1;

    while(1) {
        printf("\r\nmessage to be hashed:\r\n\r\n");
        for(i = 0; i < len ; i++) {
            printf("%c", message_input[i]);
        }

        algorithm_choose_display();
        algorithm_choose();

        mode_choose_display();
        mode_choose();

        switch(algorithm_mode_used) {
        case ALGORITHM_USE_SHA1 | MODE_USE_HASH:
            sha1_hash_demo();
            break;
        case ALGORITHM_USE_SHA224 | MODE_USE_HASH:
            sha224_hash_demo();
            break;
        case ALGORITHM_USE_SHA256 | MODE_USE_HASH:
            sha256_hash_demo();
            break;
        case ALGORITHM_USE_MD5 | MODE_USE_HASH:
            md5_hash_demo();
            break;
        case ALGORITHM_USE_SHA1 | MODE_USE_HMAC:
            sha1_hmac_demo();
            break;
        case ALGORITHM_USE_SHA224 | MODE_USE_HMAC:
            sha224_hmac_demo();
            break;
        case ALGORITHM_USE_SHA256 | MODE_USE_HMAC:
            sha256_hmac_demo();
            break;
        case ALGORITHM_USE_MD5 | MODE_USE_HMAC:
            md5_hmac_demo();
            break;
        default:
            printf("algorithm or mode error! \r\n");
            break;
        }
        printf("\r\n Example restarted...\n ");
        algorithm_mode_used = 0;
    }
}
V2.9.0:
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    /* initialize the EVAL_COM0 */
    gd_eval_com_init(EVAL_COM0);
    /* enable HAU clock */
    rcu_periph_clock_enable(RCU_HAU);

    /* message length and key length */
    len = sizeof(message_input);
    key_len = sizeof(key);

    while(1) {
        /* display the message to be hashed */
        printf("\r\nmessage to be hashed:\r\n\r\n");
        for(i = 0; i < len ; i++) {
            printf("%c", message_input[i]);
        }

        /* select algorithm */
        algorithm_choose_display();
        algorithm_choose();

        /* select mode */
        mode_choose_display();
        mode_choose();

        /* go to the corresponding hash process */
        switch(algorithm_mode_used) {
        /* when HASH SHA1 mode is selected */
        case ALGORITHM_USE_SHA1 | MODE_USE_HASH:
            sha1_hash_demo();
            break;
        /* when HASH SHA224 mode is selected */
        case ALGORITHM_USE_SHA224 | MODE_USE_HASH:
            sha224_hash_demo();
            break;
        /* when HASH SHA256 mode is selected */
        case ALGORITHM_USE_SHA256 | MODE_USE_HASH:
            sha256_hash_demo();
            break;
        /* when HASH MD5 mode is selected */
        case ALGORITHM_USE_MD5 | MODE_USE_HASH:
            md5_hash_demo();
            break;
        /* when HMAC SHA1 mode is selected */
        case ALGORITHM_USE_SHA1 | MODE_USE_HMAC:
            sha1_hmac_demo();
            break;
        /* when HMAC SHA224 mode is selected */
        case ALGORITHM_USE_SHA224 | MODE_USE_HMAC:
            sha224_hmac_demo();
            break;
        /* when HMAC SHA256 mode is selected */
        case ALGORITHM_USE_SHA256 | MODE_USE_HMAC:
            sha256_hmac_demo();
            break;
        /* when HMAC MD5 mode is selected */
        case ALGORITHM_USE_MD5 | MODE_USE_HMAC:
            md5_hmac_demo();
            break;
        default:
            printf("algorithm or mode error! \r\n");
            break;
        }
        printf("\r\n Example restarted...\n ");
        algorithm_mode_used = 0;
    }
}

__________________________________________________________________________________________________________________________

______________________I2C_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________PMU_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________RCU_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________RTC_________________________________________________________________________________________________
Fix file:
/GD32F20x_Demo_Suites/GD32F207C_EVAL_Demo_Suites/Projects/25_RTC_Calendar/main.c
fix reason:
If RCU_BDCTL_BKPRST is set, reading BKP_DATAx will cause the MCU to crash. Therefore, before reading BKP_DATAx, check whether 
RCU_BDCTL_BKPRST is set. If it is set, clear it first.
V2.8.0:
int main(void)
{
    /* COM1 config */
    gd_eval_com_init(EVAL_COM1);

    /* NVIC config */
    nvic_configuration();

    printf("\r\n This is a RTC demo...... \r\n");

    if(0xA5A5 != bkp_data_read(BKP_DATA_0)) {
        /* backup data register value is not correct or not yet programmed
        (when the first time the program is executed) */
        printf("\r\n This is a RTC demo!\r\n");
        printf("\r\n\n RTC not yet configured....");

        /* RTC configuration */
        rtc_config();

        /* adjust time by values entred by the user on the hyperterminal */
        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();
        /* change the current time */
        rtc_counter_set(time_regulate());
        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();

        bkp_data_write(BKP_DATA_0, 0xA5A5);
    } else {
        /* check if the power on reset flag is set */
        if(RESET != rcu_flag_get(RCU_FLAG_SWRST)) {
            /* check if the pin reset flag is set */
            printf("\r\n\n External Reset");
        } else if(RESET != rcu_flag_get(RCU_FLAG_PORRST)) {
            printf("\r\n\n POR occurred....");
        }

        /* wait for RTC registers synchronization */
        rtc_register_sync_wait();

        /* enable the RTC second */
        rtc_interrupt_enable(RTC_INT_SECOND);

        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();
    }

#ifdef RTCCLOCKOUTPUT_ENABLE
    /* enable PMU and BKPI clocks */
    rcu_periph_clock_enable(RCU_BKPI);
    rcu_periph_clock_enable(RCU_PMU);
    /* allow access to BKP domain */
    pmu_backup_write_enable();

    /* disable the tamper pin */
    bkp_tamper_detection_disable();

    /* enable RTC clock output on tamper Pin */
    bkp_rtc_calibration_output_enable();
#endif

    /* clear reset flags */
    rcu_all_reset_flag_clear();

    /* display time in infinite loop */
    time_show();

    while(1) {
    }
}
V2.9.0:
int main(void)
{
    /* COM1 config */
    gd_eval_com_init(EVAL_COM1);

    /* NVIC config */
    nvic_configuration();

    /* enable PMU and BKPI clocks */
    rcu_periph_clock_enable(RCU_BKPI);
    rcu_periph_clock_enable(RCU_PMU);

    /* allow access to BKP domain */
    pmu_backup_write_enable();
    if(RESET != (RCU_BDCTL | RCU_BDCTL_BKPRST)) {
        rcu_bkp_reset_disable();
    }

    /* get RTC clock entry selection */
    RTCSRC_FLAG = GET_BITS(RCU_BDCTL, 8, 9);

    printf("\r\n This is a RTC demo...... \r\n");

    if(0xA5A5 != bkp_data_read(BKP_DATA_0) || (0x00 == RTCSRC_FLAG)) {
        /* backup data register value is not correct or not yet programmed
        (when the first time the program is executed) */
        printf("\r\n This is a RTC demo!\r\n");
        printf("\r\n\n RTC not yet configured....");

        /* RTC configuration */
        rtc_config();

        /* adjust time by values entred by the user on the hyperterminal */
        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();
        /* change the current time */
        rtc_counter_set(time_regulate());
        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();

        bkp_data_write(BKP_DATA_0, 0xA5A5);
    } else {
        /* check if the power on reset flag is set */
        if(RESET != rcu_flag_get(RCU_FLAG_SWRST)) {
            /* check if the pin reset flag is set */
            printf("\r\n\n External Reset");
        } else if(RESET != rcu_flag_get(RCU_FLAG_PORRST)) {
            printf("\r\n\n POR occurred....");
        }

        /* wait for RTC registers synchronization */
        rtc_register_sync_wait();

        /* enable the RTC second */
        rtc_interrupt_enable(RTC_INT_SECOND);

        /* wait until last write operation on RTC registers has finished */
        rtc_lwoff_wait();
    }

#ifdef RTCCLOCKOUTPUT_ENABLE
    /* enable PMU and BKPI clocks */
    rcu_periph_clock_enable(RCU_BKPI);
    rcu_periph_clock_enable(RCU_PMU);
    /* allow access to BKP domain */
    pmu_backup_write_enable();

    /* disable the tamper pin */
    bkp_tamper_detection_disable();

    /* enable RTC clock output on tamper Pin */
    bkp_rtc_calibration_output_enable();
#endif

    /* clear reset flags */
    rcu_all_reset_flag_clear();

    /* display time in infinite loop */
    time_show();

    while(1) {
    }
}
__________________________________________________________________________________________________________________________

______________________SDIO________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________SYSTICK_____________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________SPI___________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________TIMER_______________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________TLI_________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________TRNG________________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________USART_______________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________USBFS_______________________________________________________________________________________________

__________________________________________________________________________________________________________________________

______________________WWDGT_______________________________________________________________________________________________

__________________________________________________________________________________________________________________________

